<template>
  <div class="tabbar-item" @click="routeCli">
    <div v-if="!isActive">
      <slot name="item-img">
      </slot>
    </div>
    <div v-else>
      <slot name="item-img-active">
      </slot>
    </div>
    <!-- <div :class="{'active':isActive}"> -->
    <div :style="{'color':isActive?color:'black'}">
      <slot name="item-text">
      </slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    routePath: {
      type: String
    },
    color: {
      type: String
      // default: 'red'
    }
  },
  data () {
    return {
      list: []
      // isActive: false
    }
  },
  methods: {
    routeCli () {
      this.$router.replace(this.routePath)
      console.log('1111', this.routePath)
    }
  },
  computed: {
    isActive () {
      return this.$route.path.indexOf(this.routePath) !== -1
    }
  }
}
</script>

<style scoped>
.tabbar-item{
  flex: 1;
  text-align: center;
  height: 49px;
  font-size: 14px;
}
.tabbar-item img{
  width: 24px;
  height: 24px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.active{
  color: red
}
</style>
